<?php

/**
 */
require_once(AD_SERVER_PATH . '/config/config.php');
require_once(AD_SERVER_PATH . '/pkgs/logger.php');
require_once(AD_SERVER_PATH . '/pkgs/utils.php');

/**
 * If local domain, set domain to empty string. Needed for cookies to work properly on localhost.
 */
$local_test = strpos($_SERVER['HTTP_HOST'], '.');

if ($local_test !== FALSE)
{
	$value = $_SERVER['HTTP_HOST'];
}
else
{
	$value = '';
}
ini_set('session.cookie_domain', $value);

/**
 * Create the various folders needed throughout the site.
 */
CUtils::create_folders();

/**
 * Create the log files used for info and debugging.
 */
$log = CLogger::get_log_list();

CLogger::clean_logs($log, AD_DEBUG_FOLDER);
CLogger::create_log($log[0]); // 0 index represents todays log

/**
 * Choose a MLS system from either a drop down or a cookie.
 */
$mls_system = CUtils::get_param('mls_system');
$mls_system = (null == $mls_system) ? 'OH_Cincinnati' : $mls_system;
$mls_config_file = (AD_SERVER_PATH . '/config/mls/'. strtolower($mls_system) . '.php');

if (file_exists($mls_config_file))
{
	require_once($mls_config_file);
}
else //
{
	die('Could not load a MLS config file.');
}

/**
 * Set the maximum search results allowed, but only if not already defined.
 */
if (!defined('AD_RETS_SEARCH_LIMIT'))
{
	define('AD_RETS_SEARCH_LIMIT', 250);
}
